/*
 * AssemblerApplication3.asm
 *
 *  Created: 2/17/2014 7:09:19 PM
 *   Author: Vincent
 */ 
	SBI DDRB, 1		;activate pin1
BEGIN:
	LDI R20,0x3D 
	STS OCR1AH,R20	;OCR1AH = 0x3D, the point where timer restarts(HIGH)
	LDI R20,0x09 
	STS OCR1AL,R20	;OCR1AL = 0x09, the point where timer restarts(LOW)
	LDI R20,0xC2 
	STS TCCR1A,R20	;CTC=0xC2=0b11000010, set on match,timer ctrl reg
	LDI R20,0x05
	STS TCCR1B,R20	;prescaler=64, timer ctrl reg
L1: IN R20,TIFR1	;timer interrrupt flag register
	SBRS R20,OCF1A	; skip next instruction if OCF1A bit = 1,output compare flag
	RJMP L1 

	LDI	R16,1<<OCF1A 
	OUT TIFR1,R16	;clear OCF1, output compare flag 
	LDI R20,0x3D 
	STS OCR1AH,R20	;OCR1AH = 0x3D, the point where timer restarts(HIGH)
	LDI R20,0x09 
	STS OCR1AL,R20	;OCR1AL = 0x09, the point where timer restarts(LOW)
	LDI R20,0x82 
	STS TCCR1A,R20	;CTC=0x82=0b10000010, clear on match, timer ctrl reg
	LDI R20,0x03
	STS TCCR1B,R20	;prescaler=64, timer ctrl reg
L2: IN R20,TIFR1 
SBRS R20,OCF1A		;skip next instruction if OCF1A = 1, output compare flag
RJMP L2 
LDI R16,1<<OCF1A	;clear OCF1A
OUT TIFR1,R16 
RJMP BEGIN 